var RM005 = {};
_Define = {};
//<option value="1">Party Room</option>
//<option value="2">Multi Pupose Room</option>
//<option value="3">Meeting Room</option>
_Define.functionRoom = { 1 : "Party Room", 2 : "Multi Pupose", 3 :"Meeting Room"};
_Define.paymentStats = { 'Y' : "YES", 'N' : "NO" };

RM005.loadDataTable = function(isSearch) {
    
        $('#dataTable')
	    .dataTable(
		    {
			bDestroy : true,
			bProcessing : false,
			bServerSide : true, 
			bLengthChange : false,
			bFilter : false,
//			"bJQueryUI": true,
			sAjaxSource : "RM005JsonAction",
//			fnServerParams : function(aoData) {
//			    // --- for search params
//			    aoData.push({
//				"name" : "user.userName",
//				"value" : $('#userName').val()
//			    }, {
//				"name" : "user.firstName",
//				"value" : $('#firstName').val()
//			    }, {
//				"name" : "user.lastName",
//				"value" :$('#lastName').val()
//			    }, {
//				"name" : "user.email",
//				"value" :$('#email').val()
//			    }, {
//				"name" : "user.role",
//				"value" :$('#role').val()
//			    }, {
//				"name" : "user.active",
//				"value" : $('#active').val()
//			    });
//			},
			columns : [ {
			    "data" : "fruhid",
			    "sClass" : "center"
			}, {
			    "data" : "rMfrudtlModel.frudrmtyp"
			}, {
			    "data" : "rMfrudtlModel.frudreqby"
			}, {
			    "data" : "rMfrudtlModel.frudpaystat",
			    "sClass" : "center"
			}, {
			    "data" : "fruhsdat",
			    "sClass" : "center"
			}, {
			    "data" : "fruhedat",
			    "sClass" : "center"
			}, {
			    "data" : "fruhstime",
			    "sClass" : "center"
			}, {
			    "data" : "fruhedtime",
			    "sClass" : "center"
			} ],
			aaSorting: [[1, 'asc']],
				columnDefs : [
						{
							render : function(data, type, row) {
								return _COMMON.ButtonRender
										.editBtn('RM005.editByUserName(\''
												+ data + '\')')
										+ '&nbsp;'
										+ _COMMON.ButtonRender
												.delBtn('RM005.onUserDelete(\''
														+ data + '\')');
							},
							targets : 0
						}, {
							render : function(data, type, row) {
								return _Define.functionRoom[data];
							},
							targets : 1
						}, {
							render : function(data, type, row) {
								return _Define.paymentStats[ data ];
							},
							targets : 3
						}, {
							'bSortable' : false,
							'aTargets' : [ 0 ]
						} ],
        });
    
};

RM005.clearHeaderCriteria = function(){

};


RM005.onUserDelete = function(name) {
//    location = 'RM005A?user.userName='+name;

    $("#confirm").html("Do you want to delete ?");

    $("#confirm").dialog({
        resizable: false,
        modal: true,
        title: "Confirm Delete",
        height: 180,
        width: 300,
        buttons: {
            "Yes": function () {
                $(this).dialog('close');
                
                location = 'RM005Adelete?pageId='+name;
                
            },
                "No": function () {
                $(this).dialog('close');
            }
        }
    });
};

RM005.editByUserName = function(name) {
    location = 'RM005Aedit?pageId='+name;
};

RM005.init = function() {
    	_COMBOBOX.PaymentStatusCombo('paymentStatus');
    	_COMBOBOX.FnRoomCombo('fnRoom');
	RM005.search();
};

$( document ).ready(function(){
	RM005.init();
});

RM005.search = function(){
	RM005.loadDataTable("true");
};

